﻿
#ifndef BoundingSphere_h
#define BoundingSphere_h

#pragma region License
/*
MIT License
Copyright ¬© 2006 The Mono.Xna Team

All rights reserved.

Authors:
Olivier Dufour (Duff)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma endregion License

#include <Typedef.h>
#include <Defines.h>
#include <CSharpPropertyMethods.h>

#include <System/Object.h>
#include <System/Byte.h>
#include <System/Array.h>
#include <System/Nullable.h>
#include <System/Math.h>
#include <System/Generic/IEquatable.h>
#include <System/Collections/Generic/IEnumerable.h>
#include <System/ArgumentOutOfRangeException.h>
#include <System/ArgumentNullException.h>
#include <System/ArgumentException.h>

#include <Riccsson/Xna/Framework/Vector3.h>
#include <Riccsson/Xna/Framework/RMatrix.h>
#include <Riccsson/Xna/Framework/ContainmentType.h>
#include <Riccsson/Xna/Framework/PlaneIntersectionType.h>

namespace Riccsson
{
	namespace Xna
	{
		namespace Framework
		{
			// Forward declerations.
			struct BoundingFrustum;
			struct BoundingBox;
			struct Ray;

			struct BoundingSphere
				: public Riccsson::System::Generic::IEquatable<BoundingSphere>
			{
				#pragma region public: Fields

				public: Vector3 Center;
				public: float Radius;

				#pragma endregion public: Fields


				#pragma region Constructors

				public: BoundingSphere();

				public: BoundingSphere(Vector3 center, float radius);

				#pragma endregion Constructors


				#pragma region public: Methods

				public: BoundingSphere Transform(Matrix matrix);

				public: void Transform(Matrix ref matrix, BoundingSphere out result);

				public: ContainmentType Contains(BoundingBox& box);

				public: void Contains(BoundingBox ref box, ContainmentType out result);

				public: ContainmentType Contains(BoundingFrustum& frustum);

				public: ContainmentType Contains(BoundingSphere sphere);

				public: void Contains(BoundingSphere ref sphere, ContainmentType out result);

				public: ContainmentType Contains(Vector3 point);

				public: void Contains(Vector3 ref point, ContainmentType out result);

				public: static BoundingSphere CreateFromBoundingBox(BoundingBox& box);

				public: static void CreateFromBoundingBox(BoundingBox ref box, BoundingSphere out result);

				public: static BoundingSphere CreateFromFrustum(BoundingFrustum& frustum);

				public: static BoundingSphere CreateFromPoints(Riccsson::System::Collections::Generic::IEnumerable<Vector3>* points);

				public: static BoundingSphere CreateMerged(BoundingSphere original, BoundingSphere additional);

				public: static void CreateMerged(BoundingSphere ref original, BoundingSphere ref additional, BoundingSphere out result);

				public: bool Equals(BoundingSphere* other);

				public: override bool Equals(Riccsson::System::object* obj);

				public: override int GetHashCode();

				public: bool Intersects(BoundingBox& box);

				public: void Intersects(BoundingBox ref box, bool out result);

				public: bool Intersects(BoundingFrustum& frustum);

				public: bool Intersects(BoundingSphere sphere);

				public: void Intersects(BoundingSphere ref sphere, bool out result);

				public: PlaneIntersectionType Intersects(Plane plane);

				public: void Intersects(Plane ref plane, PlaneIntersectionType out result);

				public: Riccsson::System::Nullable<float> Intersects(Ray& ray);

				public: void Intersects(Ray ref ray, Riccsson::System::Nullable<float> out result);

				public: override GC_PTR<Riccsson::System::string> ToString();

				#pragma endregion public: Methods
			};
			
			inline bool operator == (BoundingSphere a, BoundingSphere b)
			{
				return a.Equals(&b);
			}

			inline bool operator != (BoundingSphere a, BoundingSphere b)
			{
				return !a.Equals(&b);
			}
		}
	}
}

#endif
